package com.ash.refund;

import JavaAPI.HttpsPostRequest;
import com.ash.service.TransactionService;


import JavaAPI.*;

public class TestRefund {

    public static void main(String[] args) {
        TransactionService transactionService = TransactionService.getInstance();
        HttpsPostRequest mpgReq = transactionService.getHttpsPostRequest();

        // 支付部分退
        String amount = "0.01";
        String crypt = "7";
        String dynamic_descriptor = "123456";
        String custid = "ootdbuy";

        // 退款时需要这两个入参
        String order_id = "Test1724319363060";
        String txn_number = "186011-0_874";

        Refund refund = new Refund();
        refund.setTxnNumber(txn_number);
        refund.setOrderId(order_id);
        refund.setAmount(amount);
        refund.setCryptType(crypt);
        refund.setCustId(custid);
        refund.setDynamicDescriptor(dynamic_descriptor);

        mpgReq.setTransaction(refund);

        mpgReq.send();

        try {
            Receipt receipt = mpgReq.getReceipt();

            System.out.println("CardType = " + receipt.getCardType());
            System.out.println("TransAmount = " + receipt.getTransAmount());
            System.out.println("TxnNumber = " + receipt.getTxnNumber());
            System.out.println("ReceiptId = " + receipt.getReceiptId());
            System.out.println("TransType = " + receipt.getTransType());
            System.out.println("ReferenceNum = " + receipt.getReferenceNum());
            System.out.println("ResponseCode = " + receipt.getResponseCode());
            System.out.println("ISO = " + receipt.getISO());
            System.out.println("BankTotals = " + receipt.getBankTotals());
            System.out.println("Message = " + receipt.getMessage());
            System.out.println("AuthCode = " + receipt.getAuthCode());
            System.out.println("Complete = " + receipt.getComplete());
            System.out.println("TransDate = " + receipt.getTransDate());
            System.out.println("TransTime = " + receipt.getTransTime());
            System.out.println("Ticket = " + receipt.getTicket());
            System.out.println("TimedOut = " + receipt.getTimedOut());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

